using Digitalmes.Domain.Entities.Mes.Processes;

namespace Digitalmes.Application.Mes.Processes.StepTasks.Queries;

/// <summary>
/// 工步数据查询命令。
/// </summary>
public sealed record GetStepTaskListQuery(long StepId) : IRequest<IResult<List<ProcStepTaskDto>>>;

internal sealed class GetStepTaskListQueryHandler(IRepository<ProcStepTask> repo) : IRequestHandler<GetStepTaskListQuery, IResult<List<ProcStepTaskDto>>>
{
    public async Task<IResult<List<ProcStepTaskDto>>> Handle(GetStepTaskListQuery request, CancellationToken cancellationToken)
    {
        var items = await repo.GetListAsync(m => m.StepId == request.StepId, m => m.Seq, false, cancellationToken);
        return Result.From(items.Adapt<List<ProcStepTaskDto>>());
    }
}
